package org.cc.cloud;

import java.util.ArrayList;
import java.util.List;

import org.cc.cloud.dao.mepper.UserMepper;
import org.cc.cloud.dao.user.UserRepository;
import org.cc.cloud.domain.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DBTestController {

	@Autowired
	private UserRepository userRepository;
	@Autowired
	private UserMepper userMepper;

	@RequestMapping(value = "getUser/{guid}", method = RequestMethod.GET)
	public User getUser(@PathVariable String guid) {
		if (!StringUtils.isEmpty(guid)) {
			return userRepository.findById(guid);
		}
		return null;
	}

	@RequestMapping(value = "getAllUser", method = RequestMethod.GET)
	public List<User> getAllUser() {
		List<User> list = new ArrayList<User>();
		list.add(userMepper.getAllUser2(new User()));
		return list;
	}
}
